package com.wzdigit.wms.raw.controller.initialize.test;

import com.wzdigit.framework.exception.RestStatusException;
import com.wzdigit.framework.model.response.ErrorEntity;
import com.wzdigit.wms.raw.constant.RawWareConstant;
import com.wzdigit.wms.raw.service.initialize.test.AsnImportTestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by zyf on 2021/8/30 21:52
 */
@RestController
@Api(tags = "导入采购订单")
@RequestMapping(value = RawWareConstant.API_VERSION)
public class AsnImportTestController {
    @Autowired
    private AsnImportTestService testService;

    @ApiOperation(value = "导入《采购订单》", notes = "导入《采购订单》")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @PostMapping(value =   "ImportTest/gdn")
    public List<String> importImvTemp(MultipartFile file,
                                      HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception {
        try {
            return testService.imoprtAsnTest(file,servletRequest,servletResponse);
        } catch (RestStatusException e) {
            e.printStackTrace();
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw e;
        }
    }

}
